package com.crm.service.role;

import com.crm.pojo.Right;
import com.crm.pojo.Role;
import com.crm.repository.RightRepository;
import com.crm.repository.RoleRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Resource
    private RoleRepository roleRepository;
    @Resource
    private RightRepository rightRepository;

    @Override
    public List<Role> findAllRole() {
        return roleRepository.findAll();
    }

    @Override
    public List<Right> findAllRights() {
        return rightRepository.findAll();
    }

    @Override
    public List<Right> findRightsByRole(Role role) throws Exception {
        return rightRepository.findRightsByRolesOrderByRightCode(role);
    }
}